package pl.skubicha.service;

import java.util.List;

import javax.annotation.Resource;

import org.jboss.logging.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pl.skubicha.domain.Roles;
import pl.skubicha.repository.RoleRepository;

@Service
public class RoleRepositoryService implements RoleService {

	private static Logger logger = Logger.getLogger( RoleRepositoryService.class );

	@Resource
	private RoleRepository roleRepository;

	@Transactional( readOnly = true )
	@Override
	public List< Roles > findAll() {
		logger.debug( "Pobieram wszystkie uprawnienia" );
		return roleRepository.findAll();
	}

	@Transactional( readOnly = true )
	@Override
	public Roles findById( Integer id ) {
		return roleRepository.findOne( id );
	}
	
	@Transactional( readOnly = true )
	@Override
	public Roles findByRoleName( final String roleName ) {
		logger.debug( "Pobieram uprawnienie o nazwie: " + roleName );
		return roleRepository.findByRoleName( roleName );
	}

	public void setRoleRepository( RoleRepository roleRepository ) {
		this.roleRepository = roleRepository;
	}


}
